package com.vvlive.caibao.smartcity.ui;

import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;

import com.vvlive.caibao.smartcity.base.BaseActivity;
import com.vvlive.caibao.smartcity.base.SuperAdapter;
import com.vvlive.caibao.smartcity.bean.HelpItem;
import com.vvlive.caibao.smartcity.view.CommonActionBar;

import java.util.ArrayList;
import java.util.List;

import smartcity.vvlive.caibao.com.smartc.R;

/**
 * Created by zhj on 2015/11/18.
 */
public class CallForHelpActivity extends BaseActivity {

    private GridView mHelpItems;
    @Override
    protected int getContentViewRes() {
        return R.layout.activity_call_for_help;
    }

    @Override
    public void initWidget() {
        CommonActionBar actionBar = getCommonActionBar();
        actionBar.setTitle(R.string.func_call_for_help);
        actionBar.setMoreVisible(false);

        mHelpItems = (GridView) findViewById(R.id.help_items);

        List<HelpItem> helpItems = new ArrayList<>();
        helpItems.add(new HelpItem(R.mipmap.tech_person, "技术人员"));
        helpItems.add(new HelpItem(R.mipmap.microphone, "麦克风"));
        helpItems.add(new HelpItem(R.mipmap.paper, "白纸"));
        helpItems.add(new HelpItem(R.mipmap.sign_pen, "签字笔"));
        helpItems.add(new HelpItem(R.mipmap.tea, "茶"));
        helpItems.add(new HelpItem(R.mipmap.water, "白开水"));
        mHelpItems.setAdapter(new HelpItemsAdapter(helpItems));
        mHelpItems.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                switch (position){
                    case 0:
                        alert("呼叫技术人员");
                        break;
                    case 1:
                        alert("麦克风");
                        break;
                    case 2:
                        alert("白纸");
                        break;
                    case 3:
                        alert("签字笔");
                        break;
                    case 4:
                        alert("茶");
                        break;
                    case 5:
                        alert("白开水");
                        break;
                }
            }
        });
    }

    class HelpItemsAdapter extends SuperAdapter<HelpItem>{

        @Override
        public void onBindData(ViewHolder viewHolder, HelpItem helpItem, int position) {
            ((ImageView)viewHolder.get(R.id.help_item_icon)).setImageResource(helpItem.icon);
            ((TextView)viewHolder.get(R.id.help_item_title)).setText(helpItem.title);
        }

        public HelpItemsAdapter(List<HelpItem> dataList) {
            super(CallForHelpActivity.this, R.layout.item_help_item, dataList);
        }
    }

}
